package com.zyz.G_常用类.时间类;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: vick
 * @Date: 2025/3/19
 * @Description:
 * @version: 1.0
 */
public class Demo5 {
    public static void main(String[] args) throws ParseException {

        //日期格式化
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //格式化
        String format = simpleDateFormat.format(date);
        System.out.println(format);

        //String ==> 日期
        String date2 = "2025-03-19 20:18:29";
        SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parse = simpleDateFormat1.parse(date2);
        System.out.println(parse);
    }
}
